# permissions.py
from rest_framework import permissions

class IsFamilyAdmin(permissions.BasePermission):
    def has_object_permission(self, request, view, obj):
        return obj.admin == request.user

class HasNoFamily(permissions.BasePermission):
    message = '用户已加入其他家庭'
    def has_permission(self, request, view):
        return not hasattr(request.user, 'familymember')

class IsFamilyMember(permissions.BasePermission):
    def has_permission(self, request, view):
        return hasattr(request.user, 'familymember')